# This is a sample Python script.

# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.


def print_hi(name):
    # Use a breakpoint in the code line below to debug your script.
    print(f'Hi, {name}')  # Press Ctrl+F8 to toggle the breakpoint.


def is_palindrome(s):
    """
    判断输入字符串是否为回文。
    
    参数:
        s (str): 需要判断的字符串
        
    返回值:
        bool: 如果字符串是回文，返回 True；否则返回 False
    """
    return s == s[::-1]


def sort():
    pairs = [(1, 'one'), (2, 'two'), (3, 'three'), (4, 'four')]
    pairs.sort(key=lambda pair: pair[0])
    print(pairs)


def calculator():
    print(4 / 2)
    dict1 = dict()
    set1 = set()
    list1 = list()

    list2 = []
    set2 = ()
    dict2 = {}

    knights = {'gallahad': 'the pure', 'robin': 'the brave'}
    for k,v in knights.items():
        print(k,v)
    for knight in knights:
        print(knight)


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    print_hi('PyCharm')

    knights = {'gallahad': 'the pure', 'robin': 'the brave'}
    for k,v in knights.items():
        print(k,v)
    print()

    for key in knights:
        print(key)
    print()

    list2 = ['tic', 'tac', 'toe']
    for item in list2:
        print(item)
    print()

    for i,item in enumerate(list2):
        print(i,item)
    print()

    questions = ['name', 'quest', 'favorite color']
    answers = ['lancelot', 'the holy grail', 'blue']
    for q, a in zip(questions, answers):
        print('What is your {0}?  It is {1}.'.format(q, a))
    print()

    for q,a in zip(questions,answers):
        print(f'What is your {q}? It is {a}')
    print()

    for num in range(1,10):
        print(num)
    print()

    for num in reversed(range(1,10)):
        print(num)
    print()


# See PyCharm help at https://www.jetbrains.com/help/pycharm/
